<template>
  <div>
    <sub-header pathName="/research" :tab="tab"> </sub-header>
    <div class="rypage container">
      <div class="content_wrapper listnews">
        <ul class="content_list clearfix">
          <li
            class="item_block wow"
            style="visibility: visible; animation-name: fadeInUp"
            v-for="(item, index) in dataArr"
            :key="index"
          >
            <router-link
              class="item_box"
              :to="{ name: 'ResearchDetail', query: { id: item.id } }"
            >
              <div class="item_wrapper">
                <p class="date_wrap">
                  <span class="md">{{ item.utime | dateFormat }}</span>
                </p>
                <div class="item_info">
                  <p class="title ellipsis">
                    {{ item | filterTitle }}
                  </p>
                </div>
                <div class="item_des">
                  <p class="description">
                    {{ item | filterDescription }}
                  </p>
                </div>
              </div>
            </router-link>
            <router-link
              :to="{ name: 'ResearchDetail', query: { id: item.id } }"
              class="details"
            >
              &nbsp;&nbsp;{{ $t("detail") }}&nbsp;>
            </router-link>
            <div class="clearfix"></div>
          </li>
        </ul>
      </div>
      <pagination
        @clickPage="clickPage"
        :page="page"
        :total_page="total_page"
      ></pagination>
    </div>
  </div>
</template>
<script>
import SubHeader from '@/components/subHeader/subHeader.vue'
import { getCateData } from '@/service/getData.js'
import Pagination from '@/components/Pagination.vue'

export default {
  components: {
    'sub-header': SubHeader,
    'pagination': Pagination
  },
  data() {
    return {
      tab: 1,
      dataArr: [],
      page: 1,
      total_page: 1,
      count: 0
    }
  },
  computed: {
    cateId() {
      return this.tab + 8
    }
  },
  watch: {
    $route(to) {
      if (to.name == 'Research' && to.query.tab) {
        this.tab = +to.query.tab
        this.page = 1
        this.dataArr = []
        this.getCate()
      }
    },
  },
  created() {
    if (this.$route.query && this.$route.query.tab == 2) {
      this.tab = 2
    }
    this.getCate()
  },
  methods: {
    clickPage(page) {
      this.page = page;
      this.getCate();
    },
    async getCate() {
      let res = await getCateData(this.cateId, this.page)
      this.total_page = res.total_page | 1
      this.count = res.count | 0
      if (res && res.content && res.content.length > 0) {
        this.dataArr = res.content || []
      }
    }
  },
}
</script>
<style scoped>
.wzyear {
  padding-top: 6px;
  border-top: #eee solid 1px;
  margin-top: 15px;
  padding-left: 5px;
}
.wzyear a.sel {
  color: #233876;
  font-weight: bold;
}
.wzyear a {
  color: #333;
  padding-right: 15px;
  font-size: 15px;
  font-family: HELVETICANEUELTPRO-THEX, Arial;
}
.wzyear a:hover {
  color: #233876;
  text-decoration: underline;
}
.listnews .content_list .item_block {
  transition: all 0.36s ease;
  position: relative;
  padding: 30px 0;
  padding-top: 0;
  padding-bottom: 30px;
  border-bottom: 1px solid #e5e5e5;

  overflow: hidden;
}

.listnews .content_list .item_block::after {
  content: "";
  display: block;
  clear: both;
}

.listnews .content_list .item_block:hover {
  padding-left: 10px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
}

.listnews .content_list .item_block:hover .item_wrapper {
  margin-right: -10px;
}

.listnews .content_list .item_block:hover .item_wrapper .item_info .title {
  color: #233876;
}

.listnews .content_list .item_block:hover .details:before {
  left: 40px;
  opacity: 0;
}

.listnews .content_list .item_block:hover .details:after {
  left: 15px;
  opacity: 1;
}

.listnews .content_list .item_block:last-child {
  border-bottom-width: 0;
}

.listnews .content_list .item_block .item_img {
  float: left;
  width: 340px;
}

.listnews .content_list .item_block .item_img img {
  max-width: 100%;
}

.listnews .content_list .item_block .item_wrapper {
  transition: all 0.36s ease;
  float: left;
}

.listnews .content_list .item_block .item_wrapper .date_wrap {
  position: absolute;
  top: 76px;
  right: 27px;
  font-family: HELVETICANEUELTPRO-THEX, Arial;
}

.listnews .content_list .item_block .item_wrapper .date_wrap .year {
  font-family: inherit;
  display: none;
}

.listnews .content_list .item_block .item_wrapper .date_wrap .md {
  font-family: inherit;
  font-size: 22px;
  line-height: 30px;
}

.listnews .content_list .item_block .item_wrapper .item_info {
  /* width: calc(100% - 90px); */
  padding-right: 90px;
  padding-top: 23px;
}

.listnews .content_list .item_block .item_wrapper .item_info .title {
  font-size: 16px;
  line-height: 30px;
  color: #303030;
}

.listnews .content_list .item_block .description {
  /* width: calc(100% - 140px); */
  padding-right: 140px;
  padding-top: 11px;
  font-size: 13px;
  line-height: 26px;

  overflow: hidden;
  color: #888;
}

.listnews .content_list .item_block .details {
  position: absolute;
  width: 56px;
  top: auto;
  bottom: 10px;
  right: 20px;
  height: 26px;
  color: #888;
  border-left: 1px solid #e5e5e5;
}

.listnews .content_list .item_block .details:after,
.listnews .content_list .item_block .details:before {
  font-family: "iconfont" !important;
  speak: none;
  font-style: normal;
  font-weight: 400;
  font-variant: normal;
  text-transform: none;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  transition: all 0.36s ease;
  content: "";
  position: absolute;
  top: 50%;
  color: #999;
  font-size: 22px;
  -webkit-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  transform: translateY(-50%);
}

.listnews .content_list .item_block .details:before {
  left: 15px;
}

.listnews .content_list .item_block .details:after {
  left: -30px;
  opacity: 0;
}

.listnews .content_list .item_block .details i {
  display: none;
}

.listnews .content_list .item_block:hover {
  padding-left: 20px;
  box-shadow: 0 8px 35px rgba(0, 0, 0, 0.08);
}

.listnews .content_list .item_block .item_wrapper .date_wrap {
  top: 55px;
}

@media (max-width: 768px) {
  .listnews .content_list .item_block .item_wrapper .item_info {
    width: 100%;
    padding-top: 13px;
  }
  .listnews .content_list .item_block .item_wrapper .date_wrap {
    top: 15px;
    font-size: 10px;
  }
  .listnews .content_list .item_block .item_wrapper .item_info .title {
    font-size: 14px;
  }
  .listnews .content_list .item_block .description {
    width: 100%;
    padding-top: 6px;
    font-size: 12px;
    padding-right: 15px;
    line-height: 22px;
  }
  .listnews .content_list .item_block .item_wrapper {
    transition: all 0.36s ease;
    float: right;
    width: 100%;
  }

  .listnews .content_list .item_block .details {
    position: absolute;
    width: 56px;
    top: auto;
    bottom: 5px;
  }
}

@media screen and (max-width: 667px) {
  .listnews .content_list .item_block .item_wrapper .item_info .title {
    padding-right: 65px;
    line-height: 20px;
    margin-bottom: 5px;
  }
  .listnews .content_list .item_block .item_wrapper .date_wrap .md {
    font-size: 14px;
  }
  .listnews .content_list .item_block .item_wrapper .date_wrap {
    right: 15px;
    top: 8px;
  }
}
@media screen and (max-width: 480px) {
  .listnews .content_list .item_block .details {
    bottom: 2px;
  }
  .listnews .content_list .item_block .item_wrapper .date_wrap {
    right: 6px;
    top: 0;
  }

  .listnews .content_list .item_block .details {
    top: 110px;
    right: 0px;
    border-left: none;
  }

  .listnews .content_list .item_block .item_img img {
    max-width: calc(100% - 50px);
  }
  .listnews .content_list .item_block .item_wrapper .date_wrap {
    top: 15px;
    font-size: 8px;
  }
  .listnews .content_list .item_block .details {
    top: auto;
    bottom: 2px;
    right: 0px;
    border-left: none;
  }
}
@media screen and (max-width: 399px) and (min-width: 320px) {
  .listnews .content_list .item_block .item_img img {
    max-width: calc(100% - 90px);
  }
}
</style>